package fr.umlv.m2.jee.portailEtudiant.persistence.DAO;

import fr.umlv.m2.jee.portailEtudiant.framework.dao.hibernate.AbstractHibernateDAO;
import fr.umlv.m2.jee.portailEtudiant.persistence.Course;
import fr.umlv.m2.jee.portailEtudiant.persistence.Formation;
import fr.umlv.m2.jee.portailEtudiant.persistence.IFormationDAO;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * Created by IntelliJ IDEA.
 * User: soufiane
 * Date: 20/02/11
 * Time: 18:16
 * To change this template use File | Settings | File Templates.
 */
@Repository("hibernateFormationDAO")
public class HibernateFormationDAO extends AbstractHibernateDAO<Long, Formation> implements IFormationDAO {

    public List<Formation> findFormationById(long id) {
         return super.findByQuery("FROM Formation b WHERE b.idFormation ='"+id+"'");
    }

    @Override
    public Formation findFormationByName(String id) {
         return super.findEntityByQuery("FROM Formation  WHERE FORMATION_NAME ='"+id+"'");
    }


    @Override
    public List<Course> findCourseById(String id) {
        return super.findEntityByQuery("FROM Formation  WHERE FORMATION_NAME ='"+id+"'").getCourse();
    }
}
